<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>--%>
<html>
<head>
    <title>首页</title>
    <%@include file="/link/link-head.jsp" %>
    <base href="http://${pageContext.request.serverName}:${pageContext.request.serverPort}/">
</head>
<body>
<div style="color: red">
    ${message}
</div>
<hr>
<h3>欢迎${sessionScope.teacher.tSalutation} &nbsp;&nbsp;&nbsp <a href="teacher/logout">退出</a></h3>
<a href="add.jsp">添加学生</a>
<c:if test="${empty sessionScope.pageBean.list}">
    <h3>还灭有学生不如添加一些学生</h3>
</c:if>
<c:if test="${not empty sessionScope.pageBean.list}">
    <table border="1px">
        <tr>
            <th>index</th>
            <th>id</th>
            <th>name</th>
            <th>sex</th>
            <th>score</th>
            <th>dy</th>
            <th>birthday</th>
            <th>operate</th>
        </tr>
        <c:forEach var="student" items="${sessionScope.pageBean.list}" varStatus="index">
            <tr>
                <td>${index.index+1}</td>
                <td>${student.sId}</td>
                <td>${student.sName}</td>
                <td>${student.sGender}</td>
                <td>${student.sScore}</td>
                <td>
                    <c:if test="${student.sDy ==1}">
                        是党员
                    </c:if>
                    <c:if test="${student.sDy ==0}">
                        不是党员
                    </c:if>

                </td>
                <td>
                    <fmt:formatDate value="${student.sBirthday}" pattern="yyyy-MM-dd"/>
                </td>
                <td>
                    <c:if test="${teacher.teacherId==student.tId}">
                        <a href="student/get/${student.sId}?pageNum=${pageBean.currentPage}">修改</a>&nbsp;&nbsp;
                        <a href="student/delete/${student.sId}?pageNum=${pageBean.currentPage}">删除</a>
                    </c:if>

                    <c:if test="${teacher.teacherId!=student.tId}">
                        <span style="color: deeppink">没有权限</span>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
    </table>
</c:if>


<c:choose>
    <c:when test="${pageBean.currentPage==1}">
        <span style="color: red">前一页</span>
    </c:when>
    <c:otherwise>
        <a href="student/show?pageNum=${pageBean.currentPage-1}" style="color: green">前一页</a>
    </c:otherwise>
</c:choose>
<c:forEach begin="1" end="${pageBean.totalPage}" step="1" var="i">
    <c:if test="${pageBean.currentPage==i}">
        <a href="student/show?pageNum=${i}" style="color: hotpink">${i}</a>
    </c:if>
    <c:if test="${pageBean.currentPage!=i}">
        <a href="student/show?pageNum=${i}">${i}</a>
    </c:if>
</c:forEach>
<c:choose>
    <c:when test="${pageBean.currentPage==pageBean.totalPage}">
        <span style="color: red">后一页</span>
    </c:when>
    <c:otherwise>
        <a href="student/show?pageNum=${pageBean.currentPage+1}" style="color: green">后一页</a>
    </c:otherwise>
</c:choose>
<hr>

<a href="student/dowloadExcel">下载excel</a>

</body>
</html>
